package addbean;

import phonebookcollector.PhoneBookCollector;
import phonebookitem.PhoneBookItem;
import mainbean.MainBean;

public class AddBean extends MainBean{
	public String getForm()
	{
		String temp="";
		temp+="<form method='post' target='add.jsp'>" +
				"<p>Name:</p><input type='text' name='name'/>" +
				"<p>Firs tName:</p><input type='text' name='firstname'/>" +
				"<p>Last Name:</p><input type='text' name='lastname'/>" +
				"<p>Home Addres:</p><input type='text' name='homeaddress'/>" +
				"<p>Email</p><input type='text' name='email'/>" +
				"<p>Phone 1</p><input type='text' name='phone1'/>" +
				"<p>Phone 2</p><input type='text' name='phone2'/>" +
				"<p>Phone 3</p><input type='text' name='phone3'/><br/>" +
				"<input type='submit' name='add' value = 'add'/>" +
				"</form>";
		return temp;
	}
	
	public boolean isAdd()
	{
		if(request.getParameter("add")!=null)
		{
			PhoneBookItem item = new PhoneBookItem();
			item.setEmail(request.getParameter("email"));
			item.setName(request.getParameter("name"));
			item.setFirstName(request.getParameter("firstname"));
			item.setLastName(request.getParameter("lastname"));
			item.setHomeAddres(request.getParameter("homeaddress"));
			item.setPhone1(request.getParameter("phone1"));
			item.setPhone2(request.getParameter("phone2"));
			item.setPhone3(request.getParameter("phone3"));
			PhoneBookCollector.AddItem(item);
			return true;
		}
		return false;
	}
}
